package com.shanzhi.dify.service.impl;

import com.shanzhi.connection.common.HttpRequestType;
import com.shanzhi.dify.common.DifyUrlEnums;
import com.shanzhi.dify.service.DifyBaseService;
import com.shanzhi.dify.service.DifyChatService;
import com.shanzhi.dify.utils.DifyCommonUtils;
import com.shanzhi.dify.utils.ParseDataUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
@Slf4j
public class DifyChatServiceImpl implements DifyChatService {

    @Autowired
    private DifyBaseService difyBaseService;


    @Override
    public String getLastConversationId(String apiKey, Map<String, Object> params) {

        String conversations = difyBaseService.sendDifyRequest(null, apiKey, DifyUrlEnums.CONVERSATIONS_URL, HttpRequestType.GET, params);


//        String url = difyBaseService.getRealUrl(DifyUrlEnums.CONVERSATIONS_URL);
//        log.info("请求路径：{}", url);
////        Map<String, Object> params = new HashMap<>();
////        params.put("user", userId);
//        String conversations = DifyCommonUtils.sendDify(null, apiKey, url, HttpRequestType.GET, params);
        return ParseDataUtils.parseDataForGetLastConversationId(conversations);
    }
}
